<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<head>
    <th:block th:include="include :: header('数据源列表')" />
</head>
<body class="gray-bg">
     <div class="container-div">
        <div class="row">
            <div class="btn-group-sm" id="toolbar" role="group">
                <a class="btn btn-success" onclick="$.operate.add()">
                    <i class="fa fa-plus"></i> 添加
                </a>
            </div>
            <div class="col-sm-12 select-table table-striped">
                <table id="bootstrap-table"></table>
            </div>
        </div>
    </div>
    <th:block th:include="include :: footer" />
    <script th:inline="javascript">
        var prefix = ctx + "base/db";

        $(function() {
            $.validDB = function(idDb) {
                $.ajax({
                    url: prefix+"/testDB?idDb="+idDb,
                    cache: false,
                    contentType: false,
                    processData: false,
                    type: 'GET',
                    success: function (result) {
                        alert(result);
                    }
                });
            };
            var options = {
                url: prefix + "/list",
                createUrl: prefix + "/add",
                updateUrl: prefix + "/edit/{id}",
                removeUrl: prefix + "/remove",
                exportUrl: prefix + "/export",
                modalName: "数据源管理",
                columns: [{
                    checkbox: true
                },
                {
                    field: 'idDb',
                    title: '主键',
                    visible: false
                },
                {
                    field: 'na',
                    title: '数据源名称'
                },
                {
                    field: 'sdDbtp',
                    title: '数据源类型'
                },
                {
                    field: 'sdBuscls',
                    title: '数据源分类'
                },
                {
                    field: 'chara',
                    title: '数据库编码'
                },
                {
                    field: 'naUse',
                    title: '用户名'
                },
                {
                    field: 'fgAct',
                    title: '启用标志'
                },
                {
                    title: '操作',
                    align: 'center',
                    formatter: function(value, row, index) {
                        var actions = [];

                        actions.push('<a class="btn btn-success btn-xs " href="javascript:void(0)" onclick="$.operate.edit(\'' + row.idDb + '\')"><i class="fa fa-edit"></i>编辑</a> ');
                        actions.push('<a class="btn btn-info btn-xs " href="javascript:void(0)" onclick="$.validDB(\'' + row.idDb + '\')"><i class="fa fa-list-ul"></i>校验</a> ');
                        actions.push('<a class="btn btn-danger btn-xs " href="javascript:void(0)" onclick="$.operate.remove(\'' + row.idDb + '\')"><i class="fa fa-remove"></i>删除</a>');
                        return actions.join('');
                    }
                }]
            };
            $.table.init(options);
        });
    </script>
</body>
</html>